package com.masterclient.app.businessmodule.minemodule.redpack.adapter;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.R;
import com.masterclient.app.modules.coupon.beans.RedPackedDetailsBean;

/**
 * @auther hjian
 * @date 2020/1/2.
 */
public class RedPackedGoodsAdapter extends BaseQuickAdapter<RedPackedDetailsBean.ShMissionBean, BaseViewHolder> {

    private int type;
    public RedPackedGoodsAdapter(int type) {
        super(R.layout.item_order_goods);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, RedPackedDetailsBean.ShMissionBean item) {
        helper.setText(R.id.item_order_orderno,"订单号："+item.getSh_order_no());

        RecyclerView recyclerView = helper.getView(R.id.item_order_recyclerview);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext){
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        });

        switch (type){
            case 4:
                RedPackedGoodsChildAdapter goodsAdapter = new RedPackedGoodsChildAdapter();
                recyclerView.setAdapter(goodsAdapter);
                goodsAdapter.bindToRecyclerView(recyclerView);
                goodsAdapter.setNewData(item.getSh_list());
                break;
                default:
                    RewardBillingAdapter billingAdapter = new RewardBillingAdapter(type);
                    recyclerView.setAdapter(billingAdapter);
                    billingAdapter.bindToRecyclerView(recyclerView);
                    billingAdapter.setNewData(item.getSh_list());
        }
    }
}
